package com.atguigu.gmall.item.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/8/22 10:14
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/item")
public class ItemApiController {

    @Autowired
    private ItemService itemService;

    /**
     * 商品详情
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}")
    public Result getSkuItem(@PathVariable Long skuId){
        //  调用服务层方法
        Map map = this.itemService.getItem(skuId);
        //  返回数据
        return Result.ok(map);
    }

}
